class A:
    def __enter__(self):
        print 'in enter'

    def __exit__(self, t_type, t_value, t_traceback):
        print 'in exit'
        print str(t_type), str(t_value), str(t_traceback)
        # if retrun True, will NOT reraise the exception
        return True

with A() as a:
    print 'in 1'
    raise Exception
    print 'in 2'

print 'out with'
